package com.tionsy.springbootcomponents.config;

import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <p></p>
 * <p>
 * <PRE>
 * <BR>    修改记录
 * <BR>-----------------------------------------------
 * <BR>    修改日期         修改人          修改内容
 * </PRE>
 *
 * @author tiany
 * @version 1.0
 * @date Created in 2021年03月26日 13:54
 * @since 1.0
 */
@Configuration
public class ESConfig {
    @Value("${elasticsearch.host}")
    String esHost;
    @Value("${elasticsearch.port}")
    private Integer esPort;

    @Bean
    public RestHighLevelClient getClientConnection(){
        return new RestHighLevelClient(
                RestClient.builder(
                        new HttpHost(esHost,esPort,"http")
                )
        );
    }

}
